<script src="/vendor/laravel-admin/AdminLTE/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<script src="/vendor/laravel-admin/AdminLTE/bootstrap/js/bootstrap.min.js"></script>
<script src="/vendor/jquery/layer/layer.js"></script>
<script src="/vendor/laravel-admin/moment/min/moment-with-locales.min.js"></script>
<script src="/vendor/laravel-admin/eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="/vendor/laravel-admin/AdminLTE/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="/vendor/laravel-admin/eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min.css">
<div class="container margin-top-large">
    <div class="row">
        <form class="form-horizontal">
            <input type="hidden" name="uid" value="{{$uid}}">
            <div class="form-group ">
                <label class="control-label">请填写取消认证的原因:</label>
                <label class="control-label">
                    <textarea name="reason" rows="6" cols="90"></textarea>
                </label>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label reason-label"></label>
                <div class="row  margin-sm">
                    <button type="button" class="btn btn-default cancel">取消</button>
                    <button type="button" class="btn btn-primary submit">确认</button>
                </div>
            </div>
        </form>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        $(".submit").click(function (e) {
            let uid = $(":input[name='uid']").val();
            let reason = $(":input[name='reason']").val();

            if (reason === '') {
                parent.layer.msg('请填写取消认证的原因');
                return false;
            }
            let url = "{{url('/admin/DesignerAuth/cancel_auth/submit')}}";

            $.post(url, {
                uid: uid,
                reason: reason
            }, function (result) {
                if (result.code === 1) {
                    parent.layer.msg(result.msg);
                    timeOut();
                } else {
                    parent.layer.msg(result.msg);
                }
            });

            return false;
        });

        $(".cancel").click(function (e) {
            let index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });

        function timeOut() {
            setTimeout(function () {
                parent.window.location.reload();
            }, 200);
        }
    });
</script>